require 'ctx_rbm'
require 'dict'

torch.setdefaulttensortype('torch.DoubleTensor')

function main()
	-- load data
	local f = torch.DiskFile('newtoydata.dat', 'r')
	f:binary()
		local data = f:readObject()
		local cwdic = f:readObject() setmetatable(cwdic, Dict_mt)
		local wdic = f:readObject() setmetatable(wdic, Dict_mt)
		local cwemb = f:readObject()
		local wemb = f:readObject()
		local sampler_storage = f:readObject()
	f:close()

		nctxwords = 4
		hiddim = 200

	-- training
		print('training...')

		init_momentum = 0.9
		final_momentum = 0.9
		eps = 0.01
		weightcost = 0.001
		chainlen = 99

		nepoch = 100
		batchsize = 100

		local model = CtxRBM:new(cwemb, nctxwords, hiddim)
	
		print('training rbms...')
		model:train(data, nepoch, batchsize, init_momentum, final_momentum, 
					eps, weightcost, chainlen, sampler_storage)

end

main()


